// ****************************************************************************************************
// Table 5: Crowding with Montréal assessment roll data and our Canada-wide sample of ‘lowrise sectors’
// ****************************************************************************************************

// Writes the results as reg_montreal to $resultpath/tables/

use "$outpath/database_for_reg.dta", clear

eststo clear

//Floorspace on Montreal sample with roll data
xi: reghdfe Lnland_fwc_role dist_min_NEW i.cat0 number_NEQ number_NEQ2 number_NEQ3 number_NEQ4 Lnemp i.hoffice i.exports NBdiffbusiness NBdiffnaics4 NBdiffproduct Lndist_maj_air Lndist_stat_freight Lndist_junction if samplep==1&mtl_in==1, absorb(naics4d eruid)  vce(robust)
outreg2 using "$resultpath/tables/reg_floorspace.xls", replace $instruct keep(dist_min_NEW _Icat0_2  _Icat0_3 _Ihoffice_2  _Iexports_2 number_NEQ number_NEQ2 number_NEQ3 number_NEQ4 Lnemp  NBdiffbusiness NBdiffnaics4 NBdiffproduct  Lndist_maj_air Lndist_stat_freight Lndist_junction)

//Floorspace in Canada sample on low-rise industries as identified in roll data

gen industry="Agrifood" if naics3d==311|naics3d==312
replace industry="Textile" if naics3d==313
replace industry="Textilep" if naics3d==314|naics3d==315| naics3d==316
replace industry="Wood" if naics3d==321|naics3d==322
replace industry="Printing" if naics3d==323
replace industry="Petrol" if naics3d==324
replace industry="Chemical" if naics3d==325
replace industry="Plastics" if naics3d==326
replace industry="Nonmetallic" if naics3d==327
replace industry="Primary" if naics3d==331
replace industry="Fabricated" if naics3d==332
replace industry="Machinary" if naics3d==333
replace industry="Computer" if naics3d==334
replace industry="Electrical" if naics3d==335
replace industry="Transportation" if naics3d==336
replace industry="Furniture" if naics3d==337
replace industry="Miscellaneous" if naics3d==339

preserve 

keep if mtl_in==1

collapse (median) etage_med=etage_role (mean)  etage_mean=etage_role (max)  etage_max=etage_role (sd)  etage_sd=etage_role (count) nb_obs=etage_role, by(industry)

sort etage_mean

// br
/*
industry	etage_med	etage_mean	etage_max	etage_sd	nb_obs
Petrol	1	1	1		1
Nonmetallic	1	1.3871	3	.615219	31
Computer	1	1.5122	6	1.12076	41
Electrical	1	1.53488	8	1.45322	43
Fabricated	1	1.53947	12	1.7143	152
Textile	1	1.55556	3	.726483	9
Plastics	1	1.6	11	1.69172	85
Furniture	1	1.68627	11	1.69104	51
Transportation	1	1.73913	11	2.13664	23
Wood	1	1.81633	10	1.9966	49
Agrifood	1	1.82178	9	1.32963	101
Printing	2	2.29	13	2.37961	100
Primary	1	2.6	12	3.85079	15
Machinary	1	2.65254	47	6.60662	118
Chemical	1	2.91011	47	5.83804	89
Miscellaneous	2	3.94972	15	4.06171	179
Textilep	4	5.29448	15	4.10049	163
*/

keep industry etage_mean

save "$temppath/temp.dta", replace
restore

merge m:1 industry using "$temppath/temp.dta"
drop _m

gen low_rise= industry=="Nonmetallic"|industry=="Computer"|industry=="Electrical"|industry=="Fabricated"

// Floorspace on Montreal sample with low-rise industries only 
xi: reghdfe Lnland_fwc_role dist_min_NEW i.cat0 number_NEQ number_NEQ2 number_NEQ3 number_NEQ4 Lnemp i.hoffice i.exports NBdiffbusiness NBdiffnaics4 NBdiffproduct Lndist_maj_air Lndist_stat_freight Lndist_junction if samplep==1&mtl_in==1&low_rise==1, absorb(naics4d eruid)  vce(robust)
outreg2 using "$resultpath/tables/reg_floorspace.xls", append $instruct keep(dist_min_NEW _Icat0_2  _Icat0_3 _Ihoffice_2  _Iexports_2 number_NEQ number_NEQ2 number_NEQ3 number_NEQ4 Lnemp  NBdiffbusiness NBdiffnaics4 NBdiffproduct  Lndist_maj_air Lndist_stat_freight Lndist_junction)

// Floorspace on Canada sample with low-rise industries only 

xi: reghdfe Lnland_bwc Lnpopcma Lnareacma dist_min_NEW i.cat0 spacematep spacematep2 spacematep3 spacematep4 Lnemp i.hoffice i.exports NBdiffbusiness NBdiffnaics4 NBdiffproduct Lndist_maj_air Lndist_stat_freight Lndist_junction if samplep==1&low_rise==1, absorb(naics4d eruid) cluster(cmauid)
outreg2 using "$resultpath/tables/reg_floorspace.xls", append $instruct keep(Lnpopcma Lnareacma dist_min_NEW _Icat0_2  _Icat0_3 _Ihoffice_2  _Iexports_2 spacematep spacematep2 spacematep3 spacematep4 Lnemp  NBdiffbusiness NBdiffnaics4 NBdiffproduct  Lndist_maj_air Lndist_stat_freight Lndist_junction)
